<template>
	<!--  -->
  <a-modal
    title="发货记录"
    width="80%"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
		@cancel="handleCancel"
		:footer="null"
  >
    <a-spin :spinning="false">
      <a-form :form="form" layout="inline" labelAlign="right">
        <s-table
					ref="table"
					style="margin-top: 15px;"
					size="default"
					:columns="columns"
					:data="loadData"
					:alert="true"
				>
					<span slot="action" slot-scope="text, record">
						<a @click="$refs.deliverModal.show(record)">明细</a>
					</span>
				</s-table>
      </a-form>
    </a-spin>
		<!--  新增编辑详情弹框  -->
    <!-- <detailForm ref="detailForm" /> -->
    <deliver-modal ref="deliverModal"/>
  </a-modal>
</template>

<script>
import {page} from '@/api/modular/main/emsorder/emsOrderManage'
import {STable} from '@/components'
// import detailForm from './detailForm'
import DeliverModal from '@/views/main/productStorehouse/productDeliverOrderCompleted/deliverModal'
  export default {
		components: {
      STable, 
      // detailForm,
      DeliverModal,
    },
    data () {
      return {
				record:{},
				queryParam: {},
        columns: [
					{
						title: '序号',
						width: '80px',
						customRender: (text, record, index) => `${index + 1}`
					},
					{
						title: '发货单号',
						dataIndex: 'orderNumber'
					},
					{
						title: '操作人',
						dataIndex: 'createUserName'
					},
					{
						title: '时间',
						dataIndex: 'createTime'
					},
					{
						title: '备注',
						dataIndex: 'remark'
					},
					{
						title: '操作',
						dataIndex: '',
						scopedSlots: {customRender: 'action'}
					},
				
				],
				// 加载数据方法 必须为 Promise 对象
				loadData: parameter => {
					console.log('record',this.record)
					let query = {
						...this.queryParam,
						...parameter,
					}
					return page(query).then((res) => {
						console.log('res',res)
						return res.data
					})
				},
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this),
      }
    },
    methods: {
      // 初始化方法
      init (record) {
				this.record = {...record}
				this.queryParam.sourceOrderId = record.orderId
				this.queryParam.orderType = this.$businessEnum.ORDER_TYPE_ENUM.deliverOrder.id
        this.visible = true
				this.$refs.table.refresh(true)
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
    }
  }
</script>
